%{
#include <stdio.h>
int yylex(void);
void yyerror(char *);
extern FILE *yyin;
FILE *yyout;
%}
%union{
	float f;
	char* str;
}
%token <str> WORD DRAW
%token <f> FLOAT
%%
end: program ';'

program: draw ';' draw

draw: DRAW '(' FLOAT ',' FLOAT ',' FLOAT ',' FLOAT ')'	{fprintf(yyout, "newpath\n%f %f moveto\n%f %f lineto\nstroke\n",$3,$5,$7,$9);}

%%
void yyerror(char *s) {
extern char* yytext;
fprintf(stderr, "%s, *%s*\n", s, yytext);
}
int main(int argc, char *argv[]) {
yyin = fopen(argv[1], "r");
yyout = fopen(argv[2], "w+");
fprintf(yyout, "%%!\n");
yyparse();
fclose(yyin);
//fclose(yyout);
return 0;
}
